<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<script type="text/javascript">
$(document).ready(function(){
	var options = {
        target:      '#validationbox',
        iframe:      true,
        beforeSubmit:  function () {
			            $('#validationbox').html('<img alt="<bean:message key="saving.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="saving.message"/>');
			            $('#validationbox').dialog('open');
			        }, 
        success:    function() {
		                $('#loadattachmentbox').dialog('close');
		                reloadTicketAttachments('${pageContext.request.contextPath}/ticket/reloadticketattachments.do','${requestScope.ticketID}');
		            },    
        error:      function() {
		            	$('#validationbox').dialog('close');
                        $('#loadattachmentbox').dialog('close');
                        showErrorDialog('#dialog', 
                               { msg : "<bean:message key="upload.msg" bundle="errors"/>",
                                 boxTitle : "<bean:message key="upload.boxTitle" bundle="errors"/>",
                                 msgStatus: "<bean:message key="upload.msgStatus" bundle="errors"/>" });
                    }
     };
	
	$('#form_attachment').ajaxForm(options);
});
</script>


<html:form styleId="form_attachment" styleClass="appnitro" action="/ticket/addticketattachment.do" enctype="multipart/form-data">
	<div class="innerAttachment">
		<label class="innerAttach"><bean:message key="ticket.attach" bundle="ticket"/></label>
		<html:file property="attachmentFile" styleId="attachement" styleClass="element file" />
	</div>
	
	<div class="conteinerAttachmentResponse">
		<div class="saveAttachment">
		   <html:hidden styleId="ticketID" property="ticketID"/>
		   <html:submit styleClass="saveAttachmentButton" styleId="saveButton">
		       <bean:message key="ticket.attachmentfile" bundle="ticket"/>
		   </html:submit>
		</div>
	</div>
</html:form>